package smoothcraft.Util.mute;

import java.util.HashSet;

import org.inventivetalent.packetlistener.PacketListenerAPI;
import org.inventivetalent.packetlistener.handler.PacketHandler;
import org.inventivetalent.packetlistener.handler.ReceivedPacket;
import org.inventivetalent.packetlistener.handler.SentPacket;

import net.minecraft.server.v1_12_R1.PacketPlayInChat;

public class API {
	private static HashSet<String> set = new HashSet<String>();
	@SuppressWarnings("deprecation")
	public static void getpacket() {
		PacketListenerAPI.addPacketHandler(new PacketHandler() {
            @Override
            public void onSend(SentPacket packet) {
            }
            @Override
            public void onReceive(ReceivedPacket packet) {
            	if (packet.getPacket() instanceof PacketPlayInChat) {
            		if(set.contains(packet.getPlayername())) {
            			packet.setCancelled(true);
            		}
                }
            }
        });
	}
	public void joinSet(String name) {
		set.add(name);
	}
	public void remove(String name) {
		set.remove(name);
	}
	public boolean containsPlayer(String name) {
		return set.contains(name);
	}
}
